import { useCallback, useEffect, useState } from 'react';
import { BigNumber } from 'ethers';
import useBasisCash from './useBasisCash';
import config from '../config';

const useBalanceOf = (getBalance:()=>Promise<string>) => {
  const [balance, setBalance] = useState<string>("");
  const basisCash = useBasisCash();

  const fetchBalance = useCallback(async () => {
    setBalance(await getBalance());
  }, [basisCash?.isUnlocked,getBalance]);

  useEffect(() => {
    fetchBalance();
  }, [basisCash?.isUnlocked,getBalance]);

  return balance;
};

export default useBalanceOf;
